#!/bin/bash

apt install build-essential curl zip openjdk-8-jdk vim -y

buildpath=$(pwd)
cd $buildpath

# 下载 Command Line Tools
curl -OL https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
# 解压 Commmand Line Tools
unzip commandlinetools-linux-7583922_latest.zip

# 设置 android sdk 目录
# 配置 Command Line Tools
mkdir -pv ~/.local/android/cmdline-tools/
mv cmdline-tools ~/.local/android/cmdline-tools/latest
source ~/.bashrc
# 添加环境变量 ANDROID_NDK
echo "export ANDROID_SDK_HOME=$HOME/.local/android"  >> ~/.bashrc
source ~/.bashrc
echo "export ANDROID_NDK=$ANDROID_SDK_HOME/ndk/23.1.7779620"  >> ~/.bashrc
source ~/.bashrc
echo "export PATH=$HOME/.local/android/cmdline-tools/latest/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
# 使环境变量生效 /ndk/23.1.7779620
source ~/.bashrc
# 安装 NDK，注意这里需要同意下协议！！
sdkmanager --install "ndk;23.1.7779620"


